<?php
namespace cms\modules\v1\controllers;

use cms\modules\v1\models\access\ModuleActions;
use cms\modules\v1\models\userFund\UserMoneyLog;
use cms\modules\v1\models\userFund\WithdrawOrder;
use common\models\Functions;
use common\models\Status;
use Yii;
/**
 */
class UserFundController extends DefaultController
{
    public $modelClass = 'cms\modules\v1\models\userFund\UserMoneyLog';

    //---------------------------- 用户帐变 -------------------------------
    public function actionMoneyChangeList($page, $size) {
        $check = (new ModuleActions())->checkActions();
        if ($check !== true) {
            return Functions::formatRestAPI(1, $check);
        }
        if (Yii::$app->request->isGet) {
            $list =  (new UserMoneyLog())->getListData($page, $size);
            return $list;
        }
    }

    public function actionTag()
    {
        if (Yii::$app->request->isGet) {
            return Functions::formatRestAPI(0, '', (new UserMoneyLog())->getTags());
        }
    }

    public function actionFull($status = 0) {
        if (Yii::$app->request->isGet) {
            return (new UserMoneyLog())->getFullList($status);
        }
    }


    //余额帐变类型
    public function actionMoneyChangeTypeMap() {
        $check = (new ModuleActions())->checkActions();
        if ($check !== true) {
            return Functions::formatRestAPI(1, $check);
        }
        if (Yii::$app->request->isGet) {
            return Functions::formatRestAPI(0, '', Status::MONEY_LOG_TYPE_MAP);
        }
    }



    //============================= 提现记录 =============================
    public function actionWithdrawLogList($page = 1, $size = 50, $search = '')
    {
        $check = (new ModuleActions())->checkActions();
        if ($check !== true) {
            return Functions::formatRestAPI(1, $check);
        }
        if (Yii::$app->request->isGet) {
            $status = [
                Status::WITHDRAW_STATUS_DONE,
                Status::WITHDRAW_STATUS_FAILED
            ];
            return (new WithdrawOrder())->getListData($page, $size, $search, $status);
        }
    }
}
